package com.nwpu.coursesupport.mapper;

import com.nwpu.coursesupport.entity.CourseTarget;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseTargetDao {

    @Select(" select * from course_target ")
    List<CourseTarget> findAll();

    @Insert({"insert into course_target values (null,#{courseId},#{description},#{graduationRequirementNumber},#{weight})"})
    @Options(keyProperty = "id", keyColumn = "id", useGeneratedKeys = true)
    Integer save(CourseTarget courseTarget);

    @Update("delete from course_target where id=#{id}")
    void deleteById(@Param("id") Integer id);

    @Select("select * from course_target where course_id = #{courseId}")
    List<CourseTarget> findByCourseId(@Param("courseId") Integer courseId);
}
